home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / c / pckey.exe / PCKEY.DOC < prev    next >
Text File  |  1991-07-30  |  8KB  |  241 lines

  1.      PCKey for Borland C++
  2.      =====================
  3.  
  4.      Thank you for downloading pckey.zip!  I hope you find it 
  5.      useful and a big time saver.  It is one of many in a
  6.      series of Freeware tools from PSW.
  7.  
  8.      I used Peter Norton's "Programmer's Guide to the IBM PC & 
  9.      PS/2", copyright 1988, published by Microsoft press, as the 
  10.      only reference in coding pckey.
  11.  
  12.      The PCKey class provides access to the PC's keyboard through 
  13.      fast inline member functions.  Special characters are 
  14.      defined in the header for your convenience.  PCKey is not 
  15.      for use in Windows 3.0 programming -- use only for DOS 
  16.      applications!  I have tested PCKey with Borland C++ version 
  17.      2.0 on a PC with Award Software's 386 Modular BIOS version 
  18.      3.03a.  If you have problems running the demo please note 
  19.      your machine's BIOS manufacturer and version/copyright and 
  20.      the nature of the problem and let me know by email, phone, 
  21.      or postcard.  I will make every effort to support PCKey on 
  22.      as many machines as is practical (everyone benefits from 
  23.      user supported freeware).  You can port PCKey to other 
  24.      compilers by changing from Borland's inline pseudo variables 
  25.      to whatever style is provided by your compiler.  As a last 
  26.      resort you can convert to int86() bios calls.  Most 
  27.      compilers are being forced by the more efficient Borland 
  28.      inline assembly standard to upgrade.
  29.  
  30.      Compile and run fastkey.cpp to set your keyboard's fastest 
  31.      typematic rate/delay.  A project file for the IDE is 
  32.      provided.
  33.  
  34.      Compile pckeyd.cpp and pckey.cpp.  Then link and run 
  35.      pckeyd.exe to test the pckey.cpp module.  A project file is 
  36.      provided for this also.  Study the code in pckeyd.cpp for an 
  37.      example of using the PCKey class.
  38.  
  39.      Never instantiate any instance of the PCKey class.  There 
  40.      needs to be only one instance and that is done for you 
  41.      automatically.  The only instance of the PCKey class is 
  42.      "PCK".  Its global contructor determines whether or not an 
  43.      enhanced/extended keyboard is available.  Also, the 
  44.      typematic rate is set to the fast rate possible for quick 
  45.      keyboard response in your program.
  46.  
  47.      Member functions of the PCKey class are available via the 
  48.      instance "PCK":
  49.  
  50.  
  51.      PCK.enhanced()    returns true if an extended keyboard is 
  52.             detected.
  53.  
  54.      PCK.ascii()    returns the ascii code of the last 
  55.             character read by PCK.getch(), 
  56.             PCK.getkey() or PCK.kbhit().
  57.  
  58.      PCK.scan()        returns the scan code of the last 
  59.             character read by PCK.getch(),
  60.             PCK.getkey() or PCK.kbhit().
  61.  
  62.      PCK.getch()    Returns the ascii code of the character 
  63.             read.  Automatically calls extended BIOS 
  64.             service for enhanced keyboards.
  65.  
  66.      PCK.getkey()    Returns ascii code of regular characters 
  67.             and the negative of the scan code for 
  68.                  special characters.
  69.  
  70.      PCK.kbhit()    Returns true if key stroke is waiting.
  71.  
  72.      PCK.shift()    returns the keyboard status flags. 
  73.             Automatically calls extended BIOS service 
  74.             for enhanced keyboards.
  75.  
  76.  
  77.      The following boolean functions should be self explanatory.
  78.  
  79.  
  80.         PCK.InsertStateActive()
  81.         PCK.CapsLockActive()
  82.         PCK.NumLockActive()
  83.         PCK.ScrollLockActive()
  84.         PCK.AltPressed()
  85.         PCK.CtrlPressed()
  86.         PCK.LeftShiftPressed()
  87.         PCK.RightShiftPressed()
  88.         PCK.ShiftPressed()
  89.  
  90.         ( The next group is automatically enabled
  91.             for enhanced keyboards )
  92.  
  93.         PCK.SysReqPressed()
  94.         PCK.CapsLockPressed()
  95.         PCK.NumLockPressed()
  96.         PCK.ScrollLockPressed()
  97.         PCK.RightAltPressed()
  98.         PCK.RightCtrlPressed()
  99.         PCK.LeftAltPressed()
  100.         PCK.LeftCtrlPressed()
  101.  
  102.  
  103.      PCK.setTypeMatic()    sets typematic rate/delay.  The default 
  104.             parameters are set for the PC's default
  105.             rate.
  106.             
  107.      PCK.fastTypeMatic()  sets the typematic rate to the fastest
  108.                  available on the host machine.  PCK's
  109.             global constructor calls this function.
  110.             
  111.      PCK.fastTypeMaticOnExit() sets a flag so that the global
  112.                  destructor calls fastTypeMatic() instead
  113.             of setTypeMatic() for the default rate.                        
  114.  
  115.      PCK.putch()    writes asciiScanCode pair to keyboard 
  116.             buffer.
  117.  
  118.      PCK.flush()    flushes the keyboard buffer.
  119.  
  120.  
  121.  
  122.      The following code fragment demonstrates using the defined 
  123.      keys in pckey.hpp:
  124.  
  125.  
  126.     switch (PCK.getch())  {
  127.     case ExtendKey:
  128.     case 0:  switch(PCK.scan())  {
  129.         case F1:
  130.             ...
  131.             break;
  132.         case AltM:
  133.             ...
  134.             break;
  135.         case Home:
  136.             ...
  137.             break;
  138.         case CtrlLArr:
  139.             ...
  140.             break;
  141.  
  142.         }
  143.         break;
  144.     case ESC:
  145.         ...
  146.         break;
  147.     case CR:
  148.         ...
  149.         break;
  150.     default:
  151.         ch = PCK.ascii();
  152.         ...
  153.         break;
  154.     }
  155.     
  156.     
  157.      If you use PCK.getkey() the code would be:
  158.  
  159.     
  160.     switch (PCK.getkey())  {
  161.     case -F1:
  162.         ...
  163.         break;
  164.     case -AltM:
  165.         ...
  166.         break;
  167.     case -Home:
  168.         ...
  169.         break;
  170.     case -CtrlLArr:
  171.         ...
  172.         break;
  173.     case ESC:
  174.         ...
  175.         break;
  176.     case CR:
  177.         ...
  178.         break;
  179.     default:
  180.         ch = PCK.ascii();
  181.         ...
  182.         break;
  183.     }
  184.  
  185.  
  186.      I think you get the idea.  Just lookup the key you want in 
  187.      pckey.hpp.  If it's a special key then PCK.getch() returns 
  188.      zero or "ExtendKey" and you read the scan code from 
  189.      PCK.scan().  Be sure to read the comments for ExtendKey near 
  190.      the beginning of pckey.hpp.  Your comments and questions are 
  191.      always welcome.  John
  192.  
  193.          ----------------end-of-author's-documentation---------------
  194.  
  195.                          Software Library Information:
  196.  
  197.                     This disk copy provided as a service of
  198.  
  199.                            Public (software) Library
  200.  
  201.          We are not the authors of this program, nor are we associated
  202.          with the author in any way other than as a distributor of the
  203.          program in accordance with the author's terms of distribution.
  204.  
  205.          Please direct shareware payments and specific questions about
  206.          this program to the author of the program, whose name appears
  207.          elsewhere in  this documentation. If you have trouble getting
  208.          in touch with the author,  we will do whatever we can to help
  209.          you with your questions. All programs have been tested and do
  210.          run.  To report problems,  please use the form that is in the
  211.          file PROBLEM.DOC on many of our disks or in other written for-
  212.          mat with screen printouts, if possible.  PsL cannot debug pro-
  213.          programs over the telephone, though we can answer questions.
  214.  
  215.          Disks in the PsL are updated  monthly,  so if you did not get
  216.          this disk directly from the PsL, you should be aware that the
  217.          files in this set may no longer be the current versions. Also,
  218.          if you got this disk from another vendor and are having prob-
  219.          lems,  be aware that  some files may have become corrupted or
  220.          lost by that vendor. Get a current, working disk from PsL.
  221.  
  222.          For a copy of the latest monthly software library newsletter
  223.          and a list of the 3,000+ disks in the library, call or write
  224.  
  225.                            Public (software) Library
  226.                                P.O.Box 35705 - F
  227.                             Houston, TX 77235-5705
  228.  
  229.                                  Orders only:
  230.                                 1-800-2424-PSL
  231.                               MC/Visa/AmEx/Discover
  232.  
  233.                           Outside of U.S. or in Texas
  234.                           or for general information,
  235.                               Call 1-713-524-6394
  236.  
  237.                           PsL also has an outstanding
  238.                           catalog for the Macintosh.
  239.  
  240.  
  241.